// index.js

// 获取应用实例
const app = getApp();



Page({
  data: {
    listData:[]
  },


  // 事件处理函数
  selectBenkezy:function(e){
    
    var that = this;
    console.log(e)
    console.log(e.target.dataset.key)
    that.setData({
      theIndex: e.target.dataset.key,
      xuexiao:e.target.id
    })
    console.log(e.target.id)
  },
  go(){
    wx.redirectTo({
      url: '../../xiaoneng/xiaoneng'
    })
  },
  goTo() {
    wx.reLaunch({
      url: '../zsben/zsben'
    })
  },



  onLoad(options) {
    var that=this;
    var shengben_zy = wx.getStorageSync('shbenzhuanye');
    // var zhuanye_category = wx.getStorageSync('zhuanye_category');
    var yuanxiao = wx.getStorageSync('yuanxiao');
    that.setData({
      yuanxiao:yuanxiao,
      shengben_zy:shengben_zy
    })
    
    // console.log(zhuanye_category)
    wx.request({
      url:'https://zg99.offcn.com/index/chaxun/getlist?actid=39281&callback=?',   
      data:{
        level:'1',
        tabnum:'2',
        // Professional_category:zhuanye_category,
        benke_zy:that.data.shengben_zy,
        xuexiao:that.data.yuanxiao,
        limits: 30,
        // fenxiao: that.data.area,
        // geneal: that.data.geneal,
      },
      success: function (res) {
        console.log(res)
        var jsonStr = res.data;
        jsonStr = jsonStr.replace("(", "");
        jsonStr = jsonStr.replace(")", "");
        if (typeof jsonStr != 'object') {
          jsonStr = jsonStr.replace(/\ufeff/g, ""); //字符串转化JSON对象
          var theJson = JSON.parse(jsonStr);
        }
        console.log(theJson)
        console.log(theJson.lists)
        that.setData({
              arrt:theJson.lists,
              // nianfen:2020,
              // nainfen1:2021,
              xiaojian_fsx:theJson.lists[0].xiaojian_fsx,
              xiaojian_fsxone:theJson.lists[0].xiaojian_fsxone,
              tuiyi_fsx:theJson.lists[0].tuiyi_fsx,
              tuiyi_fsxone:theJson.lists[0].tuiyi_fsxone,
              jiandang_fsx:theJson.lists[0].jiandang_fsx,
              jiandang_fsxone:theJson.lists[0].jiandang_fsxone,
              gaoshuleibie:theJson.lists[0].gsleibie
              })
              console.log(theJson.lists[0].xiaojian_fsx)
              console.log(theJson.lists[0].xiaojian_fsxone)
              console.log(theJson.lists[0].tuiyi_fsx)
              console.log(theJson.lists[0].tuiyi_fsxone)
              console.log(theJson.lists[0].jiandang_fsx)
              console.log(theJson.lists[0].jiandang_fsxone)
            },
        
      //   if(theJson.lists.length>2){        
      //     that.setData({
      //     arrt:theJson.lists,
      //     nianfen:theJson.lists[0].nianfen,
      //     zsrs:theJson.lists[0].jihua,
      //     toudangxian:theJson.lists[0].toudangxian,
      //     nianfent:theJson.lists[2].nianfen,
      //     zsrst:theJson.lists[2].jihua,
      //     toudangxiant:theJson.lists[2].toudangxian
      //   })
      // }else{
      //   that.setData({
      //     arrt:theJson.lists,
      //     nianfen:theJson.lists[0].nianfen,
      //     zsrs:theJson.lists[0].jihua,
      //     toudangxian:theJson.lists[0].toudangxian,
      //     nianfent:'-',
      //     zsrst:'-',
      //     toudangxiant:'-'
      //   })
      // }

      //   console.log(that.data.arrt);
      //   console.log(that.data.arrt[0].nianfen);
      //   console.log(that.data.arrt[0].jihua);
      //   console.log(that.data.arrt[0].toudangxian);


        // console.log(that.data.arrt[2].nianfen);
        // console.log(that.data.arrt[2].jihua);
        // console.log(that.data.arrt[2].toudangxian);
        // console.log(that.data.arrt[0].Professional_category)
        // wx.setStorageSync('zhuanye_category',that.data.arrt[0].Professional_category)
       



    })

    // 清除缓存数据
    // wx.removeStorageSync("zhuanye")
  },
  getUserProfile(e) {
    // 推荐使用wx.getUserProfile获取用户信息，开发者每次通过该接口获取用户个人信息均需用户确认，开发者妥善保管用户快速填写的头像昵称，避免重复弹窗
    wx.getUserProfile({
      desc: '展示用户信息', // 声明获取用户个人信息后的用途，后续会展示在弹窗中，请谨慎填写
      success: (res) => {
        console.log(res)
        this.setData({
          userInfo: res.userInfo,
          hasUserInfo: true
        })
      }
    })
  },
  getUserInfo(e) {
    // 不推荐使用getUserInfo获取用户信息，预计自2021年4月13日起，getUserInfo将不再弹出弹窗，并直接返回匿名的用户个人信息
    console.log(e)
    this.setData({
      userInfo: e.detail.userInfo,
      hasUserInfo: true
    })
  }
})
